package org.voyager.service.admin.scenic.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.voyager.common.beans.JsonResult;
import org.voyager.service.admin.scenic.po.ScenicGroup;
import org.voyager.service.admin.scenic.po.ScenicGroupWithSpot;
import org.voyager.service.admin.scenic.po.ScenicSpotGroup;
import org.voyager.service.admin.scenic.service.ScenicGroupService;
import org.voyager.service.admin.scenic.vo.ScenicGroupSpotVo;

import com.alibaba.fastjson.JSONObject;

/**
 * 景点分组
 */
@RestController
@RequestMapping("/scenic/group")
public class ScenicGroupController {

	@Autowired
	private ScenicGroupService scenicGroupService;

	@PostMapping("/list")
	public JsonResult list(@RequestBody ScenicGroupWithSpot scenicGroupWithSpot) {
		return scenicGroupService.queryGroupAndSpotList(scenicGroupWithSpot);
	}

	@PostMapping(value = "/add")
	public JsonResult add(@RequestBody ScenicGroup scenicGroup) {
		return scenicGroupService.addGroup(scenicGroup);
	}

	@PostMapping("/edit")
	public JsonResult edit(@RequestBody ScenicGroup scenicGroup) {
		return scenicGroupService.modifyGroup(scenicGroup);
	}

	@PostMapping("/del")
	public JsonResult del(@RequestBody JSONObject jo) {
		return scenicGroupService.delGroupById(jo.getString("id"));
	}

	@PostMapping("/addSpot")
	public JsonResult addSpot(@RequestBody ScenicGroupSpotVo scenicGroupSpotVo) {
		return scenicGroupService.addSpot(scenicGroupSpotVo);
	}

	@PostMapping("/delSpot")
	public JsonResult delSpot(@RequestBody ScenicGroupSpotVo scenicGroupSpotVo) {
		return scenicGroupService.delSpot(scenicGroupSpotVo);
	}
	
	@PostMapping("/spotSort")
	public JsonResult spotSort(@RequestBody List<ScenicSpotGroup> ScenicSpotGroups) {
		return scenicGroupService.spotSort(ScenicSpotGroups);
	}
}
